<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Generic controller for entity class, CI AR.
 * @author hmQuan
 *
 */
class Category extends MY_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('t_category');
	}

	/**
	 * [get_list_category description]
	 * @return [type] [description]
	 */
	public function get_list_category(){
		$listCategory = $this->t_category->get_all();
		parent::print_result(array(T_CATEGORY => $listCategory), SUCCESS_VALUE);
	}

	public function get_list_infor_tag_by_category(){
		$post = $this->input->post();
		$post = parent::check_post_value($post);
		if(!isset($post[CATEGORY_ID]) || empty($post[CATEGORY_ID])){
			parent::printf_result(array(CATEGORY_ID => INVALID), FAILVALUE);
			exit();
		}

		$result = $this->t_category->get_list_tag_infor($post[CATEGORY_ID]);
		
		if(count($result) != 0){
			parent::print_result(array(T_CATEGORY => $result), SUCCESS_VALUE);
		}else{
			parent::print_result(array(T_CATEGORY => 'No found tag by category id'), FAILVALUE);
		}
		
		exit();
	}
}